home *** CD-ROM | disk | FTP | other *** search
/ Power Tools for Macintosh / Power Tools for Macintosh (SoftBit)(1992).iso / Applications / Alpha 4.01 / Alpha.4.01 / Alpha.4.01.rsrc / STR#_132.txt < prev    next >
Text File  |  1991-10-22  |  7KB  |  337 lines

  1. 
  2.  
  3. ANSI-A4 should take care of most of your library needs.
  4.  
  5. instead of A5. Linking your code with MacTraps and
  6.  
  7. but there is a version of the ANSI library that uses A4
  8.  
  9. ThinkC is fine. The ANSI library does declare globals,
  10.  
  11. global data references off of register A5. MacTraps of
  12.  
  13. be taken to ensure that the libraries don't have any
  14.  
  15. If the ACMD needs to link in library routines, care must
  16.  
  17. 
  18.  
  19. interested.
  20.  
  21. decade that comes out. IM 6 has a workaround, for those
  22.  
  23. under A/UX, and probably not under system 8.0, whatever
  24.  
  25. value of A4 on entry. Self-modifying code will not work
  26.  
  27. that these routines use self-modifying code to store the
  28.  
  29. with "RestoreA4()". MPW has similar setup routines. Note
  30.  
  31. to "RememberA0()" and "SetUpA4()", and it should end
  32.  
  33. header "SetUpA4.h", your program should begin with calls
  34.  
  35. this means is that your main file must include the
  36.  
  37. From the standpoint of a C compiler like Think C, all
  38.  
  39. their data off of register A4 instead of the usual A5.
  40.  
  41. Since ACMDs are code resources, they must reference
  42.  
  43. 
  44.  
  45. resource fork by using ResEdit.
  46.  
  47. bound to keystrokes). ACMDs can be added to Alpha's
  48.  
  49. callable from macros (macros allow ACMD functions to be
  50.  
  51. are added to the ACMD menu under 'Utilities' and are
  52.  
  53. Code resources of type 'ACMD' in Alpha's resource fork
  54.  
  55. 
  56.  
  57.   ‚Ä¢ The ACMD resource is released.
  58.  
  59. 
  60.  
  61.     transformed text.
  62.  
  63.   ‚Ä¢ The original selection is replaced with the
  64.  
  65. 
  66.  
  67.     NULL as it's result.
  68.  
  69.   ‚Ä¢ The ACMD transforms the string, and returns it or
  70.  
  71. 
  72.  
  73.     parameters.
  74.  
  75.     the text pointer and the function pointers as it's
  76.  
  77.   ‚Ä¢ The 'ACMD' resource is called as a 'C' function w/
  78.  
  79. 
  80.  
  81.     carriage returns to delimit lines.
  82.  
  83.     pointer. The string will be null-terminated w/
  84.  
  85.   ‚Ä¢ The selection (if any) is copied into the new
  86.  
  87. 
  88.  
  89.     size of the current selection + 1.
  90.  
  91.   ‚Ä¢ A new pointer is allocated with size equal to the
  92.  
  93. 
  94.  
  95.     and locked.
  96.  
  97.   ‚Ä¢ The selected code resource is loaded into memory
  98.  
  99. 
  100.  
  101. In summary, when an ACMD is called:
  102.  
  103. 
  104.  
  105. used internally.
  106.  
  107. an Alpha internal variable, only 16 bits are actually
  108.  
  109. So even while you MUST pass in a longword value to set
  110.  
  111. variables such as 'indentOnCR' and 'regExpr' are shorts.
  112.  
  113. Alpha string variables are long words, ordinary Alpha
  114.  
  115. persistent storage. Note that while user variables and
  116.  
  117. also hold pointer values, allowing ACMDs to have
  118.  
  119. defining their own variables. ACMD-defined variables can
  120.  
  121. are viewing. ACMDs can pass data among themselves by
  122.  
  123. according to the current state of Alpha and the text you
  124.  
  125. These functions allow your ACMDs to behave differently
  126.  
  127. 
  128.  
  129. 
  130.  
  131.      int deleteVar(char *name);
  132.  
  133.      *******************************************/
  134.  
  135.      *                                          *
  136.  
  137.      * Return 0 if the variable doesn't exist.  *
  138.  
  139.      * Define a longword variable named 'name'. *
  140.  
  141.      *                                          *
  142.  
  143.      /*******************************************
  144.  
  145. 
  146.  
  147. 
  148.  
  149.      int defineVar(char *name, long val)
  150.  
  151.      ************************************************/
  152.  
  153.      *                                               *
  154.  
  155.      * Return 0 if the var already exists.           *
  156.  
  157.      * Initial value 'val'.                          *
  158.  
  159.      * Define a longword variable named 'name' with  *
  160.  
  161.      *                                               *
  162.  
  163.      /************************************************
  164.  
  165. 
  166.  
  167. 
  168.  
  169.      int setVar(char *name, long val);
  170.  
  171.      ***********************************************/
  172.  
  173.      *                                              *
  174.  
  175.      * 'val' to a long when you call this routine.  *
  176.  
  177.      * a longword value for 'val', always typecast  *
  178.  
  179.      * doesn't exist. To be sure that Think passes  *
  180.  
  181.      * 'defineVar' below. Returns 0 if the var      *
  182.  
  183.      * predefined vars or those defined with        *
  184.  
  185.      * named by 'name'. Works for either Alpha      *
  186.  
  187.      * Return the longword value of the variable    *
  188.  
  189.      *                                              *
  190.  
  191.      /***********************************************
  192.  
  193. 
  194.  
  195. 
  196.  
  197.      int getVar(char *name, long *val);
  198.  
  199.      ***********************************************/
  200.  
  201.      *                                              *
  202.  
  203.      * doesn't exist.                               *
  204.  
  205.      * 'defineVar' below. Returns zero if the var   *
  206.  
  207.      * Alpha predefined vars or those defined with  *
  208.  
  209.      * named by 'name' in 'val'. Works for either   *
  210.  
  211.      * Return the longword value of the variable    *
  212.  
  213.      *                                              *
  214.  
  215.      /***********************************************
  216.  
  217. 
  218.  
  219. functions as:
  220.  
  221. Alpha variables. Internally, Alpha prototypes these
  222.  
  223. Alpha function that your ACMD can call to read or modify
  224.  
  225. Each of the last four parameters is a pointer to an
  226.  
  227. 
  228.  
  229. '%ld' instead of '%d'.
  230.  
  231. with 32-bit ints, you must print your integers with
  232.  
  233. are calling Alert from a code resource that was compiled
  234.  
  235. that Alpha is compiled with 16-bit integers, so if you
  236.  
  237. displaying the result in an alert box.  Bear in mind
  238.  
  239. accepts the same arguments as the C 'printf' command,
  240.  
  241. The 'alert' parameter is a pointer to a function that
  242.  
  243. 
  244.  
  245. display information.
  246.  
  247. ACMD to interact with Alpha's internal variables or
  248.  
  249. callback function, an Alpha function that allows your
  250.  
  251. Each of the last five arguments is a pointer to a
  252.  
  253. 
  254.  
  255. Callback Functions
  256.  
  257. 
  258.  
  259. selections.
  260.  
  261. selected text. However, macros can call ACMDs with other
  262.  
  263. is performed. 'text' is usually a copy of the currently
  264.  
  265. when the ACMD returns NULL. In this case no deallocation
  266.  
  267. block of text returned by the ACMD. The exception is
  268.  
  269. deallocating the input block. Alpha will deallocate the
  270.  
  271. two are not the same block, you are responsible for
  272.  
  273. similarly allocated block of text as its result. If the
  274.  
  275. allocated with 'NewPtr'. Your routine must return a
  276.  
  277. 'text' points to a null-terminated block of text
  278.  
  279. 
  280.  
  281.      }
  282.  
  283.         return (text);
  284.  
  285.          :     :     :
  286.  
  287.      {
  288.  
  289.      FPtr    alert, getVar, setVar, defVar, delVar;
  290.  
  291.      char    *text;
  292.  
  293.                 delVar)
  294.  
  295.      char *main(text, alert, getVar, setVar, defVar,
  296.  
  297. 
  298.  
  299.      typedef int      (*FPtr)();
  300.  
  301.      /* pointer to a function that returns an 'int' */
  302.  
  303. 
  304.  
  305. should be declared:
  306.  
  307. The following is the way the 'main' routine of your ACMD
  308.  
  309. 
  310.  
  311. play sounds.
  312.  
  313. distribution wrap text, insert the current data, and
  314.  
  315. ACMD invocations. Example ACMDs included in this
  316.  
  317. as well as define variables that Alpha maintains between
  318.  
  319. as a result. ACMDs can access Alpha flags and variables,
  320.  
  321. the text and returns a pointer to the transformed text
  322.  
  323. text (usually the selected text). The ACMD transforms
  324.  
  325. is loaded, it is passed a pointer to a chunk of file
  326.  
  327. for Alisp functions, or would be too slow. When an ACMD
  328.  
  329. typically implement functionality that is too complex
  330.  
  331. modules of user-written code to Alpha. These modules
  332.  
  333. Code resources of type 'ACMD' allow the user to add
  334.  
  335. ACMDs
  336.  
  337.